require 'flickr'
require 'singleton'
# The Gallery class is used to access the flickr API.
# It is a singleton, with new instances of the class only being created when not in memory.
class Gallery 
  include Singleton
  attr_reader :flickr
  #This method creates a new instance of a flickr object if it does not already exist. 
  #It also sets the authorization mode to false as only public access methods of the API
  #are used.
  def initialize
    if @flickr.nil?
      @flickr = Flickr.new(nil,LIGHTBOX_CONFIG[:flickr_key],LIGHTBOX_CONFIG[:flickr_shared_secret])
      @flickr.auth_mode = false
    end
  end
  #This method is used to fetch the latest photo in the users flickr photostream
  #It uses flickr.people.getPublicPhotos method of the flickr API
  def getCurrentPhoto
    return @flickr.people.getPublicPhotos(LIGHTBOX_CONFIG[:flickr_user_id],nil,1,1)
  end
  
end
